package be.xios.projectquiz.cards;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Image;
import java.awt.Toolkit;
import java.io.IOException;
import java.net.URL;

import javax.imageio.ImageIO;
import javax.swing.BorderFactory;
import javax.swing.ImageIcon;
import javax.swing.JLabel;
import javax.swing.JPanel;

/// <summary>
/// Deze klasse is een cardpanel die het logo van dit spel weergeeft op de initiele juryGUI
/// </summary>
/// <author>Sebastian Kubski</author>
/// <author>Flemming Bosch: de juiste resources gebruikt ipv /resources//*.jpg</author>
@SuppressWarnings("serial")
public class Logo extends JPanel {

	private JLabel logoLbl;
	private Dimension imgDim;
	private Image logo;
	
	public Logo() {
		this.setLayout(new BorderLayout());
		
		try {
			ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
			URL input = classLoader.getResource("logo.jpg");
			logo = ImageIO.read(input);
		} catch (IOException e) {
			   e.printStackTrace();
		}
			  
		berekenFrameSize();
			  
		ImageIcon rescaled = new ImageIcon((logo).getScaledInstance(imgDim.width, imgDim.height, java.awt.Image.SCALE_SMOOTH));
		
		logoLbl = new JLabel();
		logoLbl.setIcon(rescaled);
		logoLbl.setPreferredSize(imgDim);
		logoLbl.setBorder(BorderFactory.createLineBorder(Color.BLACK,3)); 
		
		add(logoLbl, BorderLayout.CENTER);
	}
	
	/// <summary>
	/// Deze method berekent hoe breed het logo moet zijn
	/// </summary>
	/// <author>Sebastian Kubski</author>
	public void berekenFrameSize() {
		 Toolkit toolkit =  Toolkit.getDefaultToolkit();
		 imgDim = toolkit.getScreenSize();
		 // 1/3 van het scherm voor de maxbreedte en -hoogte vd gui
		 imgDim.width  =  imgDim.width  / 3 - 10;
		 imgDim.height =  imgDim.height / 3 - 50;
	} 
}
